package brave;

import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;

public class InteractListener implements Listener
{
	@EventHandler
	public void onInteract(PlayerInteractEvent event)
	{
		// quick exit
		if (event.getAction() != Action.RIGHT_CLICK_BLOCK ||
				event.getClickedBlock().getType() != Material.WALL_SIGN)
		{
			return;
		}

		WallPlayer wallPlayer = Brave.getWallPlayer(event.getPlayer());
		
		String blockKey = event.getClickedBlock().getLocation().toString();	
		if (Brave.wallSigns.containsKey(blockKey))
		{
			IWallSign iSign = Brave.wallSigns.get(blockKey);
			iSign.onPlayerInteract(wallPlayer);
		}
	}
}
